<template>
  <div ref="pot" class="pot">
   <FormPanel
   :cols='2'
   ref="FormPanel"
   class="orderManageFormPanel"
   :list="formList"
   :formType="this.type"
   :isSubmitBtn="false"
 />
    <!-- <el-button v-show="this.type != 'show'?true:false" style="position: absolute;left: 55%;bottom: 12px;" type="primary" @click="closeDialog(false)">取消</el-button>
    <div v-show="this.type == 'show'?true:false" style="text-align: center;">
        <el-button type="primary" @click="closeDialog(false)">取消</el-button>
    </div> -->
    <div style="text-align: center;">
      <el-button type="primary" v-show="this.type == 'show'?false:true" :disabled="isDisabled" @click="formChangeHandle">保存</el-button>
      <el-button type="" @click="closeDialog(false)">取消</el-button>
    </div>
  </div>
</template>

<script>
import {
  saveReceptionist,
  updateReceptionById,
  getInfomationByMobile,
  getUsersByPosition,
  getPositions,
  getUserInfoByRolePosition
 } from '@/api/potenCus/customer/exhibition';
import {getUserInfo} from '@/api/login/index.js'
import { dictionary } from '@/utils/dictMixin';
import { phone } from '@/utils/validate'
import moment from 'moment'
export default {
  name: 'modal',
  mixins: [dictionary],
  props: {
    type: {
      type: String,
      default: 'add'
    },
    typeEdit:{
      type: String,
      default: ''
    },
    rowData: {
      type: Object,
      default: () => ({})
    },
    RolePosition:{
      type:Array,
      default:()=>([])
    }
  },
  data() {
    this.saveData = null;
    return {
      formList: this.createFormList(),
      roleType:localStorage.getItem("roleType"),
      userId:"",
      isShow:true,
      isDisabled:false,
      mobilePhone:"",
    };
  },
  created() {
    this.init();
  },
  mounted() {
    
  },
  methods: {
    
    createFormList() {
      return [
        
        {
          type: 'INPUT',
          label: '手机号',
          fieldName: 'mobilePhone',
          placeholder: '手机号',
          disabled:false,
          maxlength:11,
          rules: [{ required: false, validator: phone, trigger: 'blur' }],
          onInput:value=>{
            this.mobilePhone = value
            this.openDriveCancel()
          },
          unitRender: () => {
            return <el-button slot="append"  icon="el-icon-search" onClick={this.openDriveCancel}>查询</el-button>;
          },
        },
        {
          type: 'INPUT',
          label: '客户名称',
          fieldName: 'customerName',
          placeholder: '客户名称'
        },
        {
          type: 'SELECT',
          label: '所属顾问',
          fieldName: 'consultantCode',
          placeholder: '请选择',
          itemList: [],
          disabled:true,
          hidden:false,
        },
        /* {
          type: 'SELECT',
          label: '所属顾问',
          fieldName: 'consultantCode',
          placeholder: '请选择',
          itemList: [],
          disabled:false,
          hidden:true,
          rules: [{ required: true, message: '请选择展厅顾问', trigger: 'change' }]
        }, */
        {
          type: 'SELECT',
          label: '性别',
          fieldName: 'gender',
          placeholder: '请选择',
          itemList: this.createDictList('1002'),
          // itemList: [{ text: '先生', value: '10021001' }, { text: '女士', value: '10021002' }, { text: '未知', value: '10021003' }],
          // render: props => {
          //    return <span>{this.createDictText(parseInt(props.row.gender), '1002')}</span>;
          // }
        },
        {
          type: 'SELECT',
          label: '接待顾问',
          fieldName: 'receptionConsultant',
          placeholder: '请选择',
          itemList: [],
          rules: [{ required: true, message: '请选择展厅顾问', trigger: 'change' }]
        },
        {
          type: 'DATE_TIME',
          label: '进店时间',
          fieldName: 'arriveDate',
          placeholder: '请输入',
          filterType: 'date-range',
          dateFormat: 'yyyy-MM-dd',
          disabled:false,
          rules: [{ required: true, message: '请选择进店时间', trigger: 'change' }]
        },
        {
          type: 'DATE_TIME',
          label: '离店时间',
          fieldName: 'leaveTime',
          placeholder: '请输入',
          filterType: 'date-range',
          dateFormat: 'yyyy-MM-dd',
          initialValue:"",
          hidden:false,
          // rules: [{ required: true, message: '请选择离店时间', trigger: 'change' }]
        },
        {
          type: 'INPUT_NUMBER',
          label: '进店人数',
          fieldName: 'arrivePeopleNum',
          placeholder: '请选择',
          disabled:false,
          rules: [{ required: true, message: '请输入进店人数', trigger: 'change' }]
        },
        {
          type: 'INPUT',
          label: '意向车型',
          fieldName: 'brandSeriesModelPackageColor',
          placeholder: '意向车型',
          selfCols: 2,
          hidden:this.type == 'show'?false:true,
        },
        {
          type: 'TEXT_AREA',
          label: '备注',
          fieldName: 'remark',
          placeholder: '请选择',
          selfCols: 2,
          // style: { width: '232%' }
        },
      ];
    },
    async init() {  
      //如果是前台接待，则隐藏离店时间
      localStorage.getItem('roleType').split(',').forEach(x => {
        if(x == '10061011'){
          this.formList.find(item => item.fieldName === 'leaveTime').hidden=true;
        }
      });
      /* this.formList.find(x=>x.fieldName == "consultantCode").itemList=this.RolePosition
      this.formList.find(x=>x.fieldName == "receptionConsultant").itemList=this.RolePosition */
      // 查询所属顾问
      await getUserInfo().then(res => {
          if(res.resultCode == 200){
            let param = {
              companyId:res.data.userInfo.companyId,
              positionCode:'10061012,10061015'
            };
            getUserInfoByRolePosition(param).then(res => {
              if(res.resultCode == 200){
                let RolePosition = res.data.map(x => ({ value: x.userId, text: x.employeeName, orgId: x.orgId }));
                this.formList.find(x=>x.fieldName == "consultantCode").itemList=RolePosition
              }else{
                // this.$message.error('获取人员列表失败!');
              }
            });
          }else{
            // this.$message.error('获取当前登录用户信息失败!');
          }
        });
      // 查询接待顾问
      await getUserInfo().then(res => {
          if(res.resultCode == 200){
            let param = {
              menuId:202035,
              positionCodes:'10061015'
            };
            getUsersByPosition(param).then(res => {
              if(res.resultCode == 200){
                let RolePosition = res.data.map(x => ({value: x.userId, text: x.userName, orgId: x.orgId}));
                // this.formList.find(x=>x.fieldName == "consultantCode").itemList=RolePosition
                this.formList.find(x=>x.fieldName == "receptionConsultant").itemList=RolePosition
              }else{
                // this.$message.error('获取人员列表失败!');
              }
            });
          }else{
            // this.$message.error('获取当前登录用户信息失败!');
          }
        });
     
      await getUserInfo().then(res=>{
        //  console.log(res.data.userInfo,"res")
        this.userId=res.data.userInfo.userId
      })
      
      if (this.type != 'add') {
        // 更新接口需要的记录 ID
        this.basedataId = this.rowData.id;
        this.formList.forEach(x => {
          x.initialValue = this.rowData[x.fieldName];
        });
        // this.formList.find(x=>x.fieldName == "receptionConsultant").initialValue=this.rowData['receptionConsultant']?Number(this.rowData['receptionConsultant']):"";
        //进店时间
        if(this.rowData.arriveDate != null){
          let arriveDateNum=Number(this.rowData.arriveDate)
          let time = new Date(arriveDateNum);    //根据时间戳生成的时间对象
          let year = time.getFullYear();
          let month = time.getMonth()+1;
          let date = time.getDate();
          let hours = time.getHours();
          let minutes = time.getMinutes();
          let seconds = time.getSeconds()
          let fullDate = `${year}-${month}-${date} ${hours}:${minutes}:${seconds}`
          this.formList.find(x=>x.fieldName == "arriveDate").initialValue =fullDate;
        }
        // 离店时间
        if(this.rowData.leaveTime != null){
          let leaveTimeNum=Number(this.rowData.leaveTime)
          let time2 = new Date(leaveTimeNum);    //根据时间戳生成的时间对象
          let year2 = time2.getFullYear();
          let month2 = time2.getMonth()+1;
          let date2 = time2.getDate();
          let hours2 = time2.getHours();
          let minutes2 = time2.getMinutes();
          let seconds2 = time2.getSeconds()
          let fullDate2 = `${year2}-${month2}-${date2} ${hours2}:${minutes2}:${seconds2}`
          this.formList.find(x=>x.fieldName == "leaveTime").initialValue = fullDate2;
          // this.formList[7].initialValue = fullDate2;
        }

      }

      if (this.type == 'show'){
        this.formList.forEach(x=>{
          x.placeholder = ""
        })
        this.isShow=false
        // this.formList.find(x=>x.fieldName == "leaveTime").hidden=false
        // this.formList[7].hidden=false
        this.formList.find(x=>x.fieldName == "brandSeriesModelPackageColor").hidden=false
      }else if(this.type == 'add'){
        if(this.typeEdit == 'typeEdit'){
          this.formList.forEach(x => {
            x.initialValue = this.rowData[x.fieldName];
          });
          if(this.rowData.consultant){
            this.formList.find(x=>x.fieldName == "consultantCode").initialValue= Number(this.rowData.consultant)
          }
          this.formList.find(x=>x.fieldName == "mobilePhone").disabled = true

          if(this.formList.find(x=>x.fieldName == "customerName").initialValue){
            this.formList.find(x=>x.fieldName == "customerName").disabled = true
          }else{
            this.formList.find(x=>x.fieldName == "customerName").disabled = false
          }

          if(this.formList.find(x=>x.fieldName == "gender").initialValue){
            this.formList.find(x=>x.fieldName == "gender").disabled = true
          }else{
            this.formList.find(x=>x.fieldName == "gender").disabled = false
          }
        }
        // this.formList.find(x=>x.fieldName == "leaveTime").hidden=true
        // this.formList[7].hidden=false
        this.formList.find(x=>x.fieldName == "brandSeriesModelPackageColor").hidden=true

          let defalTime = new Date();    //根据时间戳生成的时间对象
          let year2 = defalTime.getFullYear();
          let month2 = defalTime.getMonth()+1;
          let date2 = defalTime.getDate();
          let hours2 = defalTime.getHours();
          let minutes2 = defalTime.getMinutes();
          let seconds2 = defalTime.getSeconds()
          let fullDate3 = `${year2}-${month2}-${date2} ${hours2}:${minutes2}:${seconds2}`
          this.formList.find(x=>x.fieldName == "arriveDate").initialValue = fullDate3;
          this.formList.find(x=>x.fieldName == "arrivePeopleNum").initialValue=1
         // console.log(this.roleType.split(","),'this.roleType.split(",")')
        // 判断是前台接待还是展厅顾问
        this.roleType.split(",").forEach(x=>{
          if(x == '10061011'){
            //前台接待
            // this.formList.find(x=>x.fieldName == "consultantCode").hidden=true
            // this.formList[3].hidden=false
            // this.formList.find(x=>x.fieldName == "consultantCode").disabled=false
            // this.formList.find(x=>x.fieldName == "leaveTime").hidden=true
            // this.formList[7].hidden=true

          }
          if(x == '10061015'){
            //展厅顾问10061015
            // this.formList.find(x=>x.fieldName == "consultantCode").hidden=false
            // this.formList[3].hidden=true
            
            // this.formList.find(x=>x.fieldName == "consultantCode").initialValue = this.userId
            // this.formList.find(x=>x.fieldName == "consultantCode").disabled=true
            // this.formList.find(x=>x.fieldName == "leaveTime").hidden=true
            // this.formList[7].hidden=false
          }
          if(x == "null"){
            // this.formList.find(x=>x.fieldName == "consultantCode").hidden=false
            // this.formList[3].hidden=true

            // this.formList.find(x=>x.fieldName == "leaveTime").hidden=true
            // this.formList[7].hidden=false

          }
        })
      }else{
        if(this.rowData.showEditor == 2){
          this.formList.forEach(x=>{
            x.disabled = true
            if(x.fieldName == 'leaveTime'){
              x.disabled = false
            }
          })
        }
        // this.formList.find(x=>x.fieldName == "leaveTime").hidden=false
        // this.formList[7].hidden=true
        this.formList.find(x=>x.fieldName == "brandSeriesModelPackageColor").hidden=true
         // console.log(this.roleType.split(","),'this.roleType.split(",")')
        // 判断是前台接待还是展厅顾问
        this.roleType.split(",").forEach(x=>{
          // 前台接待
          if(x == '10061011'){
            // this.formList.find(x=>x.fieldName == "consultantCode").hidden=true
            // this.formList[3].hidden=false
            // this.formList.find(x=>x.fieldName == "leaveTime").hidden=true
            // this.formList[7].hidden=true
            this.formList.find(x=>x.fieldName == "arriveDate").disabled=true
            this.formList.find(x=>x.fieldName == "arrivePeopleNum").disabled=true
          }
          // 展厅顾问
          if(x == '10061015'){
            // this.formList.find(x=>x.fieldName == "consultantCode").hidden=false
            // this.formList[3].hidden=true
            // this.formList.find(x=>x.fieldName == "leaveTime").hidden=false
            // this.formList[7].hidden=true
            this.formList.find(x=>x.fieldName == "arriveDate").disabled=true
            this.formList.find(x=>x.fieldName == "arrivePeopleNum").disabled=true
          }
          if(x == "null"){
            // this.formList.find(x=>x.fieldName == "consultantCode").hidden=false
            // this.formList[3].hidden=true
            // this.formList.find(x=>x.fieldName == "leaveTime").hidden=false
            // this.formList[7].hidden=true
          }
        })
      }
      if(this.formList.find(x=>x.fieldName == "consultantCode").initialValue){
        this.formList.find(x=>x.fieldName == "consultantCode").initialValue = Number(this.formList.find(x=>x.fieldName == "consultantCode").initialValue)
      }

      if(this.formList.find(x=>x.fieldName == "receptionConsultant").initialValue){
        this.formList.find(x=>x.fieldName == "receptionConsultant").initialValue = Number(this.formList.find(x=>x.fieldName == "receptionConsultant").initialValue)
      }
      console.log(this.formList,"初始化")
      //  console.log(this.formList.find(x=>x.fieldName == "arrivePeopleNum").hidden,"456")
    },


    openDriveCancel(){
      let pattern = /^1[2-9]\d{9}$/
      console.log(this.mobilePhone,"this.mobilePhone")
      let phoneNum =this.mobilePhone?this.mobilePhone:this.formList.find(x=>x.fieldName == "mobilePhone").initialValue

      if (phoneNum != undefined || phoneNum != '' || phoneNum != null) {
        if (pattern.test(phoneNum)) {
              getInfomationByMobile(phoneNum).then(res=>{
            if(res.data){
                  this.formList.find(x=>x.fieldName == "mobilePhone").disabled=true
                  this.formList.find(x=>x.fieldName == "customerName").initialValue = res.data.customerName
                  if(res.data.contant){
                    this.formList.find(x=>x.fieldName == "consultantCode").initialValue = Number(res.data.contant)
                  }
                  // this.formList.find(x=>x.fieldName == "receptionConsultant").initialValue = ''
                  if(res.data.contant && res.data.contant != null && res.data.contant != undefined ){
                      console.log(res.data,"待闫威确定后联调")
                      let params={
                          userId:res.data.contant,
                      }
                      getPositions(params).then(PositionData=>{
                        console.log(PositionData,"多角色")
                        PositionData.data.forEach(x=>{
                          if(x == 10061015){
                            if(!this.formList.find(x=>x.fieldName == "receptionConsultant").initialValue){
                              if(res.data.contant){
                                this.formList.find(x=>x.fieldName == "receptionConsultant").initialValue = Number(res.data.contant)
                              }
                            }
                          }
                        })
                      })
                  }
                  /* this.formList.find(x=>x.fieldName == "consultantCode") = res.data.contant
                  this.formList[3].initialValue = res.data.contant */
                  this.formList.find(x=>x.fieldName == "gender").initialValue = res.data.GENDER
                  // this.formList.forEach(ele=>{
                  //     ele.initialValue =res.data[ele.fieldName]

                  // })
                }else{
                  console.log(res.data,"待闫威确定后联调")
                }
            })
        }else{
            if(this.mobilePhone.length == 11){
                this.$message({
                  message: '请输入正确的手机号',
                  type: 'warning'
                });
            }
        }
      }

      
        
    },
    formChangeHandle() {
        this.$refs.FormPanel.SUBMIT_FORM()
        console.log(123,this.formList.find(x=>x.fieldName == "receptionConsultant").initialValue)
        if(!this.formList.find(x=>x.fieldName == "receptionConsultant").initialValue||
          this.formList.find(x=>x.fieldName == "arriveDate").initialValue == undefined||
          this.formList.find(x=>x.fieldName == "arrivePeopleNum").initialValue == null){
        }else{
          
          if(this.formList.find(x=>x.fieldName == "mobilePhone").initialValue){
            if(this.formList.find(x=>x.fieldName == "mobilePhone").initialValue.length > 11){
              this.$message({
                message: '请输入正确手机号',
                type: 'warning'
              });
            }else{
                let pattern = /^1[3-9]\d{9}$/
                if (pattern.test(this.formList.find(x=>x.fieldName == "mobilePhone").initialValue)) {
                  
                    let params={
                    employeeNo:"",
                    arrivePeopleNum:"",
                    consultantCode: "",
                    customerName: "",
                    receptionConsultant:"",
                    receptionOrgId:"",
                    gender: "",
                    arriveDate: "",
                    leaveTime: "",
                    mobilePhone: "",
                    remark: "",
                    buttonType:0,
                    model:"",
                    id:this.rowData.id,
                  }
                  if(this.typeEdit == 'typeEdit'){
                    params.taskId = this.rowData.actionId
                  }
                  console.log(this.formList,"this.formList")
                  this.formList.forEach(x=>{
                      Object.keys(params).map(k=>{
                        if(x.fieldName == k){
                          params[k]=x.initialValue
                        }
                      })
                    })
                  params.receptionConsultant =this.formList.find(x=>x.fieldName == "receptionConsultant").initialValue
                  this.formList.find(x=>x.fieldName == "receptionConsultant").itemList.map(x=>{
                    console.log(x,"x",params.receptionConsultant)
                    if(params.receptionConsultant == x.value){
                        params.receptionOrgId = x.orgId
                    }
                  })
                  params.arriveDate=Date.parse(this.formList.find(x=>x.fieldName == "arriveDate").initialValue)
                  if(this.formList.find(x=>x.fieldName == "leaveTime").initialValue){
                    params.leaveTime=Date.parse(this.formList.find(x=>x.fieldName == "leaveTime").initialValue)
                  }/* else if(this.formList[7].initialValue){
                    params.leaveTime=Date.parse(this.formList[7].initialValue)
                  } */else{
                    params.leaveTime=''
                  }
                  
                  // if(this.formList.find(x=>x.fieldName == "consultantCode")){
                      params.consultantCode=this.formList.find(x=>x.fieldName == "consultantCode").initialValue
                  // }else{
                      // params.consultantCode=this.formList[3].initialValue
                  // }
                  console.log(params,"params")
                  
                  let arriveDate1 = new Date(params.arriveDate);
                  let leaveTime2 = new Date(params.leaveTime);
                  // let leaveTime3 = new Date(Date.parse(this.formList[7].initialValue));
                  // 进店时间
                  let arriveDateYear1  =  arriveDate1.getFullYear()
                  let arriveDateMonth1 =  arriveDate1.getMonth()
                  let arriveDateDate1  =  arriveDate1.getDate()
                  // 离店时间1
                  let leaveTimeYear2 =  leaveTime2.getFullYear()
                  let leaveTimeMonth2 = leaveTime2.getMonth()
                  let leaveTimeDate2 =  leaveTime2.getDate()
                  let d=new Date()
                  // 离店时间2
                  // let leaveTimeYear3 =  leaveTime3.getFullYear()
                  // let leaveTimeMonth3 = leaveTime3.getMonth()
                  // let leaveTimeDate3 =  leaveTime3.getDate()
                  
                  if(params.leaveTime){
                        if(params.leaveTime < params.arriveDate){
                            this.$message({
                              message: '离店时间应大于进店时间',
                              type: 'warning'
                            });

                        }else if(arriveDateYear1 != leaveTimeYear2){
                            this.$message({
                              message: '离店时间必须与进店时间为同一天',
                              type: 'warning'
                            });
                        }else if(arriveDateMonth1 != leaveTimeMonth2){
                            this.$message({
                              message: '离店时间必须与进店时间为同一天',
                              type: 'warning'
                            });
                        }else if(arriveDateDate1 != leaveTimeDate2){
                            this.$message({
                              message: '离店时间必须与进店时间为同一天',
                              type: 'warning'
                            });
                        }/* else if(params.leaveTime > Date.parse(d)){
                            this.$message({
                              message: '离店时间必须小于当前时间',
                              type: 'warning'
                            });
                        } */else{
                                this.saveDialog(params)
                        }
                  }else{
                      this.saveDialog(params)
                  }
                  
                }else{
                  this.$message({
                    message: '请输入正确手机号',
                    type: 'warning'
                  });
                }
            }
          }else{
                let params={
                employeeNo:"",
                arrivePeopleNum:"",
                consultantCode: "",
                receptionConsultant:"",
                receptionOrgId:"",
                customerName: "",
                gender: "",
                arriveDate: "",
                leaveTime: "",
                mobilePhone: "",
                remark: "",
                buttonType:0,
                model:"",
                id:this.rowData.id?this.rowData.id:'',
                orgId:"",
              }
              if(this.typeEdit == 'typeEdit'){
                params.taskId = this.rowData.actionId
              }
              console.log(this.formList,"this.formList")
              this.formList.forEach(x=>{
                  Object.keys(params).map(k=>{
                    if(x.fieldName == k){
                      params[k]=x.initialValue
                    }
                  })
                })
              params.receptionConsultant =this.formList.find(x=>x.fieldName == "receptionConsultant").initialValue
              this.formList.find(x=>x.fieldName == "receptionConsultant").itemList.map(x=>{
                console.log(x,"x",params.receptionConsultant)
                if(params.receptionConsultant == x.value){
                    params.receptionOrgId = x.orgId
                }
              })
              params.arriveDate=Date.parse(this.formList.find(x=>x.fieldName == "arriveDate").initialValue)
              if(this.formList.find(x=>x.fieldName == "leaveTime").initialValue){
                params.leaveTime=Date.parse(this.formList.find(x=>x.fieldName == "leaveTime").initialValue)
              }/* else if(this.formList[7].initialValue){
                params.leaveTime=Date.parse(this.formList[7].initialValue)
              } */else{
                params.leaveTime=''
              }
              // if(this.formList.find(x=>x.fieldName == "consultantCode")){
                  params.consultantCode=this.formList.find(x=>x.fieldName == "consultantCode").initialValue
                  console.log(this.formList.find(x=>x.fieldName == "consultantCode").itemList)
                  this.formList.find(x=>x.fieldName == "consultantCode").itemList.map(x=>{
                    if(params.consultantCode == x.value){
                        params.orgId = x.orgId
                    }
                  })
              // }else{
              //     params.consultantCode=this.formList[3].initialValue
              //     console.log(this.formList[3].itemList)
              //     this.formList.find(x=>x.fieldName == "consultantCode").itemList.map(x=>{
              //       if(params.consultantCode == x.value){
              //           params.orgId = x.orgId
              //       }
              //     })
              // }
              
              let arriveDate1 = new Date(params.arriveDate);
              let leaveTime2 = new Date(params.leaveTime);
              // let leaveTime3 = new Date(Date.parse(this.formList[7].initialValue));
              // 进店时间
              let arriveDateYear1  =  arriveDate1.getFullYear()
              let arriveDateMonth1 =  arriveDate1.getMonth()
              let arriveDateDate1  =  arriveDate1.getDate()
              // 离店时间1
              let leaveTimeYear2 =  leaveTime2.getFullYear()
              let leaveTimeMonth2 = leaveTime2.getMonth()
              let leaveTimeDate2 =  leaveTime2.getDate()
              let isHaveLeaveTim=false
              let d=new Date()
              
              console.log(Date.parse(d),"Date.parse(d)",params.leaveTime)
              if(params.leaveTime > 0){
                isHaveLeaveTim=true
              }else{
              }
              if(isHaveLeaveTim){
                  if(params.leaveTime < params.arriveDate){
                      this.$message({
                        message: '离店时间应大于进店时间',
                        type: 'warning'
                      });

                  }else if(arriveDateYear1 != leaveTimeYear2){
                      this.$message({
                        message: '离店时间必须与进店时间为同一天',
                        type: 'warning'
                      });
                  }else if(arriveDateMonth1 != leaveTimeMonth2){
                      this.$message({
                        message: '离店时间必须与进店时间为同一天',
                        type: 'warning'
                      });
                  }else if(arriveDateDate1 != leaveTimeDate2){
                      this.$message({
                        message: '离店时间必须与进店时间为同一天',
                        type: 'warning'
                      });
                  }/* else if(params.leaveTime > Date.parse(d)){
                      this.$message({
                        message: '离店时间必须小于当前时间',
                        type: 'warning'
                      });
                  } */else{
                    this.saveDialog(params)
                  }
              }else{
                this.saveDialog(params)
              }
          }
          // saveReceptionist(params).then(res=>{
          //   // console.log(res,"Res123")
          //   if(res.resultCode == 200){
          //      this.closeDialog(false,'refresh')
          //   }
          // })

        }
    },
    async saveDialog(params) {
      if(this.roleType2 == 10061011){
        if(this.formList[3].initialValue){
          let d=new Date()
          let currentDate = moment().format('YYYY-MM-DD')
          console.log("currentDate",`${moment(params.arriveDate).format('YYYY-MM-DD')}`,currentDate)
          if(this.type != 'edit' && `${moment(params.arriveDate).format('YYYY-MM-DD')}` != `${currentDate}`) {
            this.$message({
              message: '进店时间为当天时间',
              type: 'warning'
            });
          }else if(this.type != 'edit' && params.arriveDate > Date.parse(d)){
              this.$message({
                message: '进店时间必须小于当前时间',
                type: 'warning'
              });
          }else{
              this.isDisabled=true
            // this.$refs.formPanel.SUBMIT_FORM();
            // if (this.saveData !== null) {
              console.log(params,"菽粟")
              if(this.type =='add'){
                params.id=""
              }
              let res = {};
              if (this.type === 'add') {
                params.employeeNo=params.consultantCode
                res = await saveReceptionist(params);
              }
              if (this.type === 'add1') {
                res = await saveReceptionist(params);
              }
              if (this.type === 'edit') {
                params.taskId=this.rowData.taskId
                params.employeeNo=params.consultantCode
                res = await saveReceptionist(params);
              }
              if (res.resultCode === 200) {
                this.isDisabled = false
                this.$message({
                  message: '保存成功',
                  type: 'success'
                });
                this.closeDialog('refresh');
              }else{
                this.isDisabled=false
              }
          }
        }
      }else{
        let d=new Date()
      let currentDate = moment().format('YYYY-MM-DD')
      console.log("currentDate",`${moment(params.arriveDate).format('YYYY-MM-DD')}`,currentDate)
      if(this.type != 'edit' && `${moment(params.arriveDate).format('YYYY-MM-DD')}` != `${currentDate}`) {
        this.$message({
          message: '进店时间为当天时间',
          type: 'warning'
        });
      }else if(this.type != 'edit' && params.arriveDate > Date.parse(d)){
          this.$message({
            message: '进店时间必须小于当前时间',
            type: 'warning'
          });
      }else{
          this.isDisabled=true
        // this.$refs.formPanel.SUBMIT_FORM();
        // if (this.saveData !== null) {
          console.log(params,"菽粟")
          if(this.type =='add'){
            params.id=""
          }
          let res = {};
          if (this.type === 'add') {
            params.employeeNo=params.consultantCode
            res = await saveReceptionist(params);
          }
          if (this.type === 'add1') {
            res = await saveReceptionist(params);
          }
          if (this.type === 'edit') {
            params.taskId=this.rowData.taskId
            params.employeeNo=params.consultantCode
            res = await saveReceptionist(params);
          }
          if (res.resultCode === 200) {
            this.isDisabled = false
            this.$message({
              message: '保存成功',
              type: 'success'
            });
            this.closeDialog('refresh');
          }else{
            this.isDisabled=false
          }
      }
      }
      
    },
    closeDialog(param) {
      this.$emit('close', false, param);
    }
  }
};
</script>

<style lang="less">
// .pot{
//   position: relative;
//   .orderManageFormPanel{
//   .el-form .el-row:nth-child(2) .el-col {
//     position: relative;
//     left: 35%;
//     .el-form-item__content .el-button:last-child{
//       display: none;
//     }
//   }
// }
// }
</style>
